package com.jeff.android.lab.architecture.arouter;

import android.content.Context;
import android.os.Bundle;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.facade.service.PretreatmentService;
import com.jeff.android.lab.commonlib.router.Constant;
import com.jeff.utils.security.AESUtil;

/**
 * 预处理服务
 *
 * @author: dingfeng
 * @date: 2021/1/25
 * @since: 1.0.0
 **/
@Route(path = "/pretreatment/service")
public class PretreatmentServiceImpl implements PretreatmentService {
    @Override
    public boolean onPretreatment(Context context, Postcard postcard) {
        // 跳转前预处理，如果需要自行处理跳转，该方法返回 false 即可

        if (Constant.ACTIVITY_URL_LOGIN.equals(postcard.getPath())) {
            final String name = postcard.getExtras().getString(Constant.NAME);
            try {
                postcard.withString(Constant.NAME,  AESUtil.decrypt(name));
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
        return true;
    }

    @Override
    public void init(Context context) {

    }
}
